7. processing and sorting machine modular approach 4

因此,我们设法以模块化的方式为提取站和情人编写代码。
So we managed to write the code, the modular way for the extraction station and for the lover.

现在让我们前往电梯。
Now let's move on to the elevator.

让我们保留提取站作为参考。
Let's keep the extraction station as a reference.

让我们首先在这里添加相同的变量,我们在该州其他站中使用的局部变量作为无符号整数,整个州也是一个无符号整数。
And let's start by adding over here the same variables, the local variables that we used in other stations in the state as an unsigned integer, the whole state, that's an unsigned integer as well.

并将所有请求者作为布尔变量。
And the all the requester as a boolean variable.

好的,让我们重新开始,再次讨论状态变量的情况。
OK, so let's start again and have our case for the state variable again.

让我们从零状态开始,这意味着该站已禁用。
Let's start from a zero state, which means that the station is disabled.

让我们复制这里的构造站内容,然后转到状态 10。
And let's copy what we have here for the construction station and let's move to state 10.

好的。
OK.

现在,我们正在启动我们的机器,我们正在启动电梯,所以首先,我们需要发出电梯的嗡嗡声。
So right now, we are starting our machine, we are starting the elevator, so first of all, we would need to carry out the humming of the elevator.

不幸的是,只有当杠杆不碍事时我们才能做到这一点。
Unfortunately, we can do this only if the lever is out of the way.

因此,在第一个状态下,我们将等待杠杆离开,因为如果杠杆不在左侧,我们对电梯就无能为力,因为杠杆将在途中。
So over here in the first state, we shall wait for the lever to be left, because if the lever isn't on the left, there is not much we can do with our elevator because the lever will be on the way in the way.

因此,让我们继续下去,直到找到操纵杆左侧位置传感器。
So let's ride that until we get the lever left position sensor.

那时我们将留在该州。
We will stay in the state then.

因此,如果杠杆左侧位置传感器等于 true。
So if lever left position sensors gets equal to true.

这是正确的。
That's right.

该状态变为等于 20。
That state becomes equal to 20.

好的,现在让我们进入状态 20,天气不好,让我们开始吧。
OK, so let's get to state 20 right now, the weather is out of the way and let's.

在这里,我们要做的就是把电梯向下移动。
Here, what we need to do is to move the elevator down.

至按钮传感器。
To the button sensor.

所以在这里,让我们尝试向下移动等于尝试向下移动,向上移动等于下降,这样,如果到达底部,电梯就会向下移动,这意味着我们有电梯底部传感器,那么我们应该停止电梯。
So here, let's try to move the down equal to try to move it down and move elevator up equal to falls this way, the elevator will move down if we get to the bottom, meaning that we have the elevator bottom sensor, then we shall stop the elevator.

因此,将电梯向下移动,成为福尔瑟姆。
So move elevator down, become Folsom.

我们可以避免写这个,但为了完整,我们会这样做。
We can avoid writing this, but we will in order to be complete.

所以在这里我们停止电梯,我们得到了一个等于 30 个国家座位的隧道。
So here we stop the elevator and we get a tunnel of state seat equal to 30.

好的,现在我们的电梯处于底部,我们将等待产品被放置在电梯上。
OK, so we got to the to a state where our elevator is at the bottom right now, we shall wait for a product to be placed on the elevator.

不仅如此,我们还需要其他两个条件,因为在我们开始移动之前我们还需要再次留下肝脏。
And not only that, but we will need the other two conditions because we shall as well need the liver to be left again before we started moving.

然后我们还应该确保钻孔站上没有产品。
And then we shall also should also make sure that there is no product already on the drilling station.

所以在这里我们会看到我们正在等待产品。
So here we will see that we wait for product.

电梯很少让我们看到,所以直到我们在电梯上有产品时,电梯上的产品,我们有水平左侧位置传感器,而不是钻孔站上的产品。
And the elevator rarely lets see, so until if if we have a product on the elevator, product on elevator, and we have that our level left position sensor and not a product on the drilling station.

那么我们应该做的就是让我们的状态等于40,如果这里的状态等于40,这意味着我们有一个产品和一个电梯,我们应该向上移动。
Then what we should do is get our state to state equal to 40, if the state is equal to 40 here, it means that we have a product and an elevator and we shall move up.

因此,我们有一个更向上的四个状态,其中我们需要执行与状态 20 中所做的相反的操作,这意味着它们必须移动。
So we have a four state that is more elevator up in which we need to do the opposite of what we did in state 20, meaning that they have to move.

稍后我们将复制这个。
And later we shall copy this.

假设只是复制这个。
Let's say just copy this.

对不起。
Sorry.

让我们删除这些线,我们需要做的实际上是向上移动,因此向下移动电梯应为假,向上移动应为真。
Let's remove these lines and what we need to do is actually to move up, so move elevator down shall be false and move up shall be true.

好的,直到我们到达电梯停止传感器。
OK, until we reach the elevator stop sensor.

好的,这太棒了。
OK, this is great.

现在让我们再次移动,电梯向下,但我们已经有一个状态了。
Now let's we shall move again, the elevator down, but we already have a state for that.

那是320。
That is 320.

所以当我们到达这里时,我们可以简单地移动到 20。
So when we get here, we can simply move to 20.

好的,我们管理了电梯的几乎所有座位。
OK, so we manage that almost all the seats for our elevator.

还有。
And the.

好吧,现在我们应该可以出发了。
OK, right now, we we should be actually good to go.

也许我们可以在这里检查的另一件事是我们。
Maybe another thing that we can check here is that we.

好吧,让我们在这里添加另一个状态,我将解释为什么,因为如果我们到达这个状态 50,这意味着我们的电梯作为产品并且到达了钻井站。
Well, let's add another state here and I will explain why, because if we get we get to this state 50, it means that our elevator as a product and it reached the drilling station.

但让我们等待产品被卸载。
But let's wait for the product to be unloaded.

这意味着电梯传感器这个产品应该等于 false。
This means that the product, an elevator sensor, should become equal to false.

所以在这里,让我们等待,等待产品被卸载到捕鲸站,我们在这里可以做的是,如果电梯上没有产品,那么我们将回到等于 20 的状态,这是用于移动捕鲸站的状态。电梯下行。
So here, let's wait right, wait for product to be unloaded onto the whaling station and what we can right here is that if not product on elevator, then we shall get back to state equal to 20, which is the one used to move the elevator down.

好的,然后我们实际上可以从提取状态复制所有这些代码。
OK, and then we can actually copy all this code from the extraction state.

当然,我们会从这里添加一些东西。
Of course, we will add something so from here.

我们可以,您可以单击此处,然后全部移动,然后单击此处,这就是复制和粘贴。
We can you can click here and all shift and then click over here, that's a copy and paste.

那么让我们看看现在需要添加什么。
So let's see what we need to add it right now.

我们先从应急管理开始。
Let's start from the emergency management.

当我们处于紧急状态时,我们需要停止电梯。
When we are in an emergency state, we need to stop the elevator.

所以我们实际上有两种方法可以做到这一点。
So we have actually two ways to do this.

我们可以在这里向下移动电梯应该等于跌落,并且向上移动电梯,否则当我们现在到达零四状态时我们不能只是乘坐它。
We can right here that move elevator down should be equal to falls as well as move elevator up or we cannot just ride it when we get to states zero four now.

这是正确的。
That's right.

这是你的.
Is this your.

这样就可以处理紧急情况了。
And in this way, emergency is handled.

电梯无论在哪里都会停止,对于停止的到来,我们需要在这里得到等于 1000 的状态,我们需要等到电梯到达一个感应或另一个感应,这样我们就可以在这里,如果我们已经将电梯向下移动或移动。
The elevator will stop wherever it is, and for the stop coming and we need we will get to state equal to one thousand here and we will need to wait until the elevator as reached the one sense or the other so we can right here that if we have move elevator down or move.

不,抱歉。
No, sorry.

我的意思是正确的电梯到传感器或电梯按钮传感器,那么我们应该移动到等于零的状态,同时禁用传感器。
I mean the right elevator to the sensor or elevator button sensor, then we should move to state equal to zero while disabling the sensor.

阻止它。
Stopping it.

使用我们在紧急情况下使用的相同线路。
Using the same lines that we used into the emergency.

好的,所以我们成功了这一站,让我们看看这里的整个请求,一切都会好起来的。
OK, so we managed this stop and look let's look at the whole request here, everything shall be fine.

我们唯一需要研究的是,有些状态是不允许我们持有的,而且也许有一种状态不适合我们持有。
The only thing that we need to look into is there are some states in which we are not allowed to hold and that maybe one state that is not good for us to hold.

我的意思是,电梯移动时也有两个状态,即状态 20 和状态 40。
I mean, two states as well are the ones in which the elevator is moving, meaning state 20 and state 40.

因此,当另一个请求被确认时,我们还需要在此处添加条件,即我们需要状态不同于 20,并且状态也不等于 40。
So when another request is acknowledged, let's also add to condition here that we need state to be different to 20 and state to be not equal as well to 40.

好的,我们就可以出发了。
OK, we shall be good to go.

让我们构建它来检查我们是否犯了一些错误。
Let's build it to see the check if we made some mistakes.

好吧,我们必须解决。
OK, we have to address.

哦,是的,我忘记了最后的盒子。
Oh, yeah, I forgot that the encase at the end.

让我们按 F 11 来构建零错误的构建。
Let's build pressing F 11 with zero errors on the build.

因此,让我们打开可视化并测试电梯。
So let's open our visualization and let's test the elevator as well.

让我们执行下载并按开始。
Let's carry out the download and let's press start.

送货就是取货。
Delivery is picking up the product.

电梯仍然没有动。
The elevator is still not moving.

现在正在左、右层等待,电梯启动正常。
It is waiting for level left and right now, the elevator started OK.

那太棒了。
That's great.

我们可以看到,我们开始看到一些东西开始并行工作,而我们实际上正在等待,因为大脑不工作了。
We can see we are starting to see something getting to life to work in parallel and we are actually holding because the brain is not working.

所以到目前为止,我想一切都很好。
So up to now, I guess everything is fine.

让我们停下来重新开始清理产品。
Let's stop and start again to clear the products.

现在我们就到电梯顶部的中途。
And let's right now the top of the elevator midway.

因此,当电梯移动时,我们的压力机就会停止。
So our press stop when the elevator is moving.

哦对不起。
Oh, sorry.

我会的,当情况下降时我会按下它。
I will I will press it when this is going down.

我停了下来,好吧,现在车站已经不运行了。
I stopped, OK, and now the station is not running.

好吧,让我在这里再试一次。
Well, let me try this again here.

我将保留这个车站呼叫,以便我们可以看到车站何时真正到达未运行的圣..
I will keep this station call so we can see when the stations actually reach the not running St..

所以这里再按一次启动,电梯上行时我会按停止。
So press start here again, and I will press stop when the elevator is moving up.

停止。
Stop.

您可以看到,状态对于暂时停止仍然至关重要。
You can see that the state has remained crucial to stopping for a little bit.

所以电梯停在这里,这是正确的。
So the elevator stopped here and this is correct.

让我们开始看看即将发生的事情。
Let's start and see the looming.

好的,我们开始吧。
OK, there we go.

好吧,让我们尝试一下持有。
Well, let's try with holding.

所以。
So.

电梯一动,我就按保持,我按了所有,但机器仍在运行。
As soon as the elevator moves, I will press hold, I pressed all but the machine is still running.

是的,这很棒,因为电梯一直运行,直到达到可以保持的状态。
Yeah that is great because the elevator kept running until it reached the state in which holding was possible.

所以现在,我删除了热按钮。
So right now, I removed the hot button.

一切都从原来的地方开始,这太棒了。
Everything starts back from where it was, and this is great.

我们可以看到我们的机器,它正在变得栩栩如生。
We can see our machine, this is coming to life.

我们现在唯一需要尝试的就是紧急情况。
The only thing that we need to try now is the emergency.

那么我们来试试电梯运行时的紧急情况。
So let's try the emergency when the elevator is moving.

现在,好吧,他们最好在产品中途停止,这很好,这正是我们想要的,让我们消除紧急情况并开始并观察程序的发生。
And now, OK, they are better stopped midway with a product, this is good, this is exactly what we wanted and let's remove the emergency and start and see the procedure happening.

好的,当您设法实现时,这非常棒。
OK, so this is great when you manage to implement the.

电梯,现在我们将前往烤架和桌子上的最后一个。
Elevator and right now we will move on to the grill and the last on the table.